﻿using EntityFrameworkLayer.Entities;
using EntityFrameworkLayer.Service;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace DemoEntityFramework
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private MaterialService materialService;

        public MainWindow()
        {
            InitializeComponent();
            materialService = new MaterialService();
        }

        private void btn_create_Click(object sender, RoutedEventArgs e)
        {
            Random rnd = new Random();            
            Material material = new Material() 
            {
                SeriousNumber = "SN" + rnd.Next(100),
                Name = "Cash-Material" + rnd.Next(100),
                Classify = "Cls1",
                Cost = rnd.Next(100),
                CostUnit = "USD",
                Quantity = rnd.Next(100),
                QuantityUnit = "piece"
            };
            materialService.Create(material);
            MessageBox.Show("Add Successful");
        }

        private void btn_load_Click(object sender, RoutedEventArgs e)
        {
            this.dgrMaterial.DataContext = materialService.GetAll();
            MessageBox.Show("Load Successful");
        }
    }
}